from wxpyview.ui.component.common.basewidget import *

class Tab(Widget):
    def _getParentParam(self, meta_widget):
        parent = meta_widget.getParentMetaWidget().getWidget()
        parent_class_name = parent.__class__.__name__
        if parent_class_name != 'Notebook':
            raise IOException
        
        return parent

    def _setParams(self, meta_widget):
        dom = meta_widget.getDOM()
        if not dom:
            raise IOException
        
        self.params["parent"] = self._getParentParam(meta_widget)
        self.params["label"] = dom.getAttribute("label")
        self.params["name"] = dom.getAttribute("name")

    def getParent(self):
        return self.params["parent"]
    
    def getLabel(self):
        return self.params["label"]

    def create(self, meta_widget):
        self._setParams(meta_widget)
        
        return self